<?php
namespace Controller;
use Kuyuan\WqCore\controller\Controller;
use Model\SettingMediaModel;

/**
 * 素材库参数设置
 * Class Media
 * @package Controller
 */
class SettingMedia extends Controller
{

    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 获取素材库参数
     */
    public function find()
    {
        $_setting = SettingMediaModel::where("uniacid",$this->_uniacid)
                                    ->noGetAttr(false)
                                    ->cache(!KUYUAN_DEBUG)
                                    ->find();
        if(!$_setting){
            SettingMediaModel::create(
                array(
                    "uniacid"=>$this->_uniacid
                )
            );
            return $this->find();
        }
        return $_setting;
    }

    /**
     * 设置素材库参数
     * @param array $_data 修改的数据
     * @return mixed
     */
    public function set($_data)
    {
        return SettingMediaModel::where("uniacid",$this->_uniacid)
                ->update($_data);
    }

}